home *** CD-ROM | disk | FTP | other *** search
/ USGS: Oil & Gas Potential…National Wildlife Refuge / USGS - Oil & Gas Potential of the Arctic National Wildlife Refuge - Disc 2.iso / mac / MEcode / MEANWR1a.txt < prev    next >
Text File  |  1999-02-11  |  21KB  |  685 lines

  1.  MEANWR1a.doc.
  2.  
  3. ' ANWR Results Program for Nig/Aurora 2-play case
  4. '
  5. '  Note that this algorithm is DIFFERENT from that used in
  6. '   other plays
  7. '
  8. '  Description: This is a Monte Carlo simulation program to
  9. '    compute estimated in-place and recoverable oil and gas
  10. '    resources by play.
  11. '  Input: Input data is obtained from Excel 97 worksheets Oil,
  12. '    and Play-Prospect.
  13. '  Output: The principal output is specified in worksheet
  14. '    Summary.  It consists of estimates of the mean and
  15. '    standard deviation and selected quartiles of in-place
  16. '    and recoverable oil, NGL, and gas.  Size-frequency
  17. '    distributions are given in worksheet Distns.
  18. '    Supplementary results used to check the program and data
  19. '    are given in worksheet Supple
  20. '    In addition, three ASCII files are created:
  21. '     ProspData is detailed prospects data
  22. '     PlayData is summary data by simulation run
  23. '     HydroData is first 100 records-hydro output for testing
  24. '  Operating instructions: In the Excel 97 Workbook go to
  25. '    Tools, Macro, Macros.  Then run ANWR1a_VBA.
  26. '
  27. ' Written in Visual Basic for Applications (Excel 97)
  28. '  John H. Schuenemeyer, USGS, 3/31/98-3pm
  29.  
  30. Option Explicit
  31. 'Declarations
  32. Private user_sheet  As Object
  33. Private data_sheet  As Worksheet
  34. Private chart_range As Range
  35. Private chart_sheet As Chart
  36. Private outer_max   As Integer
  37. Private outer_index As Integer
  38. Private inner_max   As Integer
  39.  
  40. Sub ANWR1a_VBA()
  41. 'Define variables
  42. Dim i, j, m, ni, nj, fsc, os, minfs, njknt As Integer
  43. Dim r12, orf, grf, fNig, fcond, fNc As Variant
  44. Dim fAur, fAc, u1 As Variant, nsw As Integer
  45. Dim proboil, adg, adgr As Variant
  46. Dim GOR, ag, gor1, gor2 As Variant
  47. Dim gast, gastr As Variant
  48. Dim so, sor, nglr1, nglr2 As Variant
  49. Dim sngl, snglr, sg, sgr As Variant
  50. Dim pd, fvf1, fvf2, fvf, depth, depthadd As Variant
  51. Dim nglratio, ngl, nglr, nglt, ngltr As Variant
  52. Dim nglrar As Variant, nglra As Variant
  53. Dim nglrag As Variant, nglrag1 As Variant, nglrag2 As Variant
  54. Dim temp, temp1, temp2 As Variant
  55. Dim press, press1, press2, press3, press4 As Variant
  56. Dim zc As Variant, zc1 As Variant, zc2 As Variant
  57. Dim marray As Integer, seed As Integer
  58. Dim OilR As Variant, OilA As Variant, GasR As Variant, GasA As Variant
  59. Dim ProsDist As Variant, njr As Variant, TotClos As Variant
  60. Dim Mclos As Variant, Ntotc As Integer, Pclos As Variant
  61. Dim mdiv, playa, mplaya As Variant
  62. Dim z(1 To 6), TotR(1 To 7), maxfsc(1 To 14)
  63. Dim TotIP(1 To 7), NumDep(1 To 4), NDRep(1 To 2)
  64. Dim SumIP(1 To 7) As Double, SumR(1 To 7) As Double
  65. Dim Sum2IP(1 To 7) As Double, Sum2R(1 To 7) As Double
  66. Dim tmpIP, tmpR As Variant, c(1 To 7)
  67.  
  68. 'Obtain input values from worksheets
  69.  
  70. Worksheets("Play-Prospect").Activate
  71.  Range("h18").Select
  72.   fNig = Selection.Value  'prob of favorable Nig
  73.  Range("h24").Select
  74.   fAur = Selection.Value  'prob of favorable Aurora
  75.  Range("g26").Select
  76.   fcond = Selection.Value  'prob of favorable Aurora
  77.  Range("g30").Select
  78.   proboil = Selection.Value 'prob prospect is oil
  79.  Range("f3").Select
  80.   minfs = Selection.Value   'cutoff value
  81.  Range("j8:k14").Select
  82.   ProsDist = Selection.Value 'num of prospects distn
  83.  
  84. Worksheets("Oil").Activate
  85.   Range("c4").Select
  86.    playa = Selection.Value  'Play area in thousand of acres
  87.   Range("g19").Select
  88.    depthadd = Selection.Value 'Surface to sea level
  89.   Range("c22").Select         ' thousands of feet
  90.    orf = Selection.Value    'oil rcovery factor, %
  91.    orf = orf * 0.01
  92.   Range("c26").Select
  93.    fvf1 = Selection.Value   'fvf equation parameter
  94.   Range("e26").Select
  95.    fvf2 = Selection.Value   'fvf equation parameter
  96.   Range("c29").Select
  97.    gor1 = Selection.Value   'GOR equation parameter
  98.   Range("e29").Select
  99.    gor2 = Selection.Value   'GOR equation parameter
  100.   Range("c31").Select
  101.    nglr1 = Selection.Value  'ngl ratio eqn parameter
  102.   Range("e31").Select
  103.    nglr2 = Selection.Value  'ngl ratio eqn parameter
  104.   Range("j10:u16").Select
  105.    pd = Selection.Value     'hydro volume parameters
  106.    
  107. Worksheets("Gas").Activate
  108.   Range("d19").Select
  109.    grf = Selection.Value   'gas rcovery factor, %
  110.    grf = grf * 0.01
  111.   Range("c23").Select
  112.    nglrag1 = Selection.Value   'ngl+cond to NA gas eqn parameter
  113.   Range("e23").Select
  114.    nglrag2 = Selection.Value   'ngl+cond to NA gas eqn parameter
  115.   Range("d42").Select
  116.    press1 = Selection.Value   'gas press eqn parameter
  117.   Range("f42").Select
  118.    press2 = Selection.Value   'gas press eqn parameter
  119.   Range("d43").Select
  120.    press3 = Selection.Value   'gas press eqn parameter
  121.   Range("f43").Select
  122.    press4 = Selection.Value   'gas press eqn parameter
  123.   Range("d45").Select
  124.    temp1 = Selection.Value   'gas temp eqn parameter
  125.   Range("f45").Select
  126.    temp2 = Selection.Value   'gas temp eqn parameter
  127.   Range("d47").Select
  128.    zc1 = Selection.Value   'gas compress eqn parameter
  129.   Range("f47").Select
  130.    zc2 = Selection.Value   'gas compress eqn parameter
  131.  
  132. Worksheets("Distns").Activate 'In place
  133.   Range("b5:n6").Select
  134.    so = Selection.Value     'store num of dep & total oil
  135.   Range("b9:n12").Select    'gas
  136.    sg = Selection.Value
  137.   Range("b16:n18").Select   'ngl
  138.    sngl = Selection.Value
  139.   Range("b22:n23").Select   'Recoverable
  140.    sor = Selection.Value    'store num of dep & in-place oil
  141.   Range("b26:n29").Select
  142.    sgr = Selection.Value    'gas-recoverable
  143.   Range("b33:n35").Select   'ngl
  144.    snglr = Selection.Value
  145. Worksheets("Supple").Activate  'supplementary results
  146.   Range("e5").Select
  147.    Mclos = Selection.Value
  148.    
  149. 'Clear arrays
  150. marray = 13     'marray is the maximum number of log 2 classes
  151. For j = 1 To marray
  152.  For i = 1 To 2
  153.   so(i, j) = 0
  154.   sor(i, j) = 0
  155.  Next i
  156.  For i = 1 To 3
  157.   sngl(i, j) = 0
  158.   snglr(i, j) = 0
  159.  Next i
  160.  For i = 1 To 4
  161.   sg(i, j) = 0
  162.   sgr(i, j) = 0
  163.  Next i
  164. Next j
  165. For j = 1 To 7
  166.  SumIP(j) = 0
  167.  SumR(j) = 0
  168.  Sum2IP(j) = 0
  169.  Sum2R(j) = 0
  170. Next j
  171. ' The following array stores the maximum field size classes
  172. ' Order is oil,ngl,gas for in place and then recoverable
  173. For i = 1 To 14
  174.  maxfsc(i) = 0
  175. Next i
  176. For i = 1 To 4
  177.  NumDep(i) = 0
  178. Next i
  179. Mclos = 0
  180. Ntotc = 0
  181.  
  182. Open "ProspData" For Output As #1    ' Open file for output.
  183. Write #1, "SimNum", "ProspNum", "O1G2", "O/G", "Closure", "Depth", "Other params"
  184. Open "PlayData" For Output As #2
  185. Write #2, "SimNum", "OilR", "AssDGas", "NA_Gas", "All_Gas", "NGL_ADG", "NGL_NAG", "All_NGL"
  186. Open "HydroData" For Output As #3    ' Open file for output.
  187. Write #3, "SimNum", "ProspNum", "O1G2", "O/G", "Thick", "Closure", "Porosity", "100-WS", "TrapFill"
  188. 'Open "testd" For Output As #9
  189.  
  190. m = 10000 'm is num of simulation runs=num successful plays
  191. mdiv = m 'total number of plays
  192. seed = -199 'random number seed, negative integer
  193. Rnd (seed)  'initializes uniform random number generator
  194. ' subtraction for computing variance if needed
  195. c(1) = 0 '3500 'est for in place oil mean
  196. c(2) = 0 '1900 'est for in place assoc diss gas mean
  197. c(3) = 0 '10500 'est for in place NA gas mean
  198. c(4) = c(2) + c(3) 'est for in place total gas mean
  199. c(5) = 0 '1900 'est for in place ngl from assoc diss gas mean
  200. c(6) = 0 '10500 'est for in place ngl from NA gas mean
  201. c(7) = c(5) + c(6) 'est for in place total ngl mean
  202.  
  203. 'main simulation loop
  204. For i = 1 To m
  205.  For j = 1 To 7
  206.   TotR(j) = 0
  207.   TotIP(j) = 0
  208.  Next j
  209. NDRep(1) = 0
  210. NDRep(2) = 0
  211. TotClos = 0
  212. njknt = 0
  213. ' Call SingleS(ProsDist, 1, njr)
  214. ni = 2  'CInt(njr)     'ni is number of prospects
  215.  
  216. ' Prospect loop
  217. nj = 1
  218. fNc = fNig     'set fav uncond prob
  219. fAc = fAur
  220. nsw = 0
  221. ' Check favorability of nj th prospect
  222. Line10:
  223. u1 = Rnd()
  224. If nsw <> 1 And u1 < fNc Then
  225.  nsw = 1         'get Nig
  226. ElseIf nsw <> 2 And u1 < fNc + fAc Then
  227.   nsw = 2        'get Aur
  228. Else
  229.   nsw = 3        'no reservoir found
  230.   If nj = 2 Then GoTo Line60   'no reserviors 2nd pass
  231. End If
  232.  On nsw GoTo Line30, Line30, Line20
  233. Line20:
  234.  nj = 2              'no reser 1st pass
  235.  GoTo Line10
  236. Line30:
  237.  njknt = njknt + 1   'count of successful prospects in play i
  238. ' Write #9, i, njknt, nsw, fNc, fAc, u1
  239.  ngl = 0
  240.  nglra = 0
  241.  nglr = 0
  242.  nglrar = 0
  243.  GasA = 0
  244.  adg = 0
  245.  GasR = 0
  246.  adgr = 0
  247.  
  248. ' Is reservoir oil or gas?
  249.  If Rnd() < proboil Then
  250. 'OIL
  251.  
  252.  os = 1     'oil reservoir
  253.   Call SingleS(pd, 11, depth)   'Sample depth
  254.   depth = depth + depthadd
  255. 'In-place oil, mm bbl
  256. 'formation volume factor
  257.   If depth < 2.17 Then     ' thousands of feet
  258.    fvf = 1
  259.   Else
  260.    If depth > 12.15 Then   ' thousands of feet
  261.     fvf = 1.5
  262.      Else
  263.     fvf = fvf1 + fvf2 * depth
  264.    End If
  265.   End If
  266.   
  267.   Call SampleOHVP(z, pd, fvf, minfs)  'get size >=cutoff
  268.   OilA = z(6)
  269.   Call SizeClass(OilA, maxfsc(1), marray, fsc)
  270.   so(1, fsc) = so(1, fsc) + 1
  271.   so(2, fsc) = so(2, fsc) + OilA
  272.   NDRep(1) = NDRep(1) + 1
  273.   TotIP(1) = TotIP(1) + OilA
  274.   
  275. 'in place assoc-dissolved gas, billions of cu. ft.
  276.   GOR = 10 ^ (gor1 + gor2 * depth)
  277.   adg = OilA * GOR * 0.001  '.001 for billions of cu. ft.
  278.   Call SizeClass(adg / 6, maxfsc(2), marray, fsc)
  279.   sg(2, fsc) = sg(2, fsc) + adg
  280.   TotIP(2) = TotIP(2) + adg
  281.     
  282. ' in place ngl from assoc-diss gas, millions bbl
  283.   If depth >= 15.674 Then
  284.     nglratio = 100     'units=bbl/millions cu ft
  285.     Else
  286.     nglratio = 1000000 / (nglr1 * Exp(nglr2 * depth))
  287.   End If
  288.   ngl = adg * nglratio * 0.001 ' ngl, millions bbl
  289.   Call SizeClass(ngl, maxfsc(5), marray, fsc)
  290.   sngl(1, fsc) = sngl(1, fsc) + ngl
  291.   TotIP(5) = TotIP(5) + ngl
  292.   
  293.  ' recoverable oil, mm bbl
  294.  OilR = OilA * orf   ' orf recoverable oil
  295.   Call SizeClass(OilR, maxfsc(8), marray, fsc)
  296.   sor(1, fsc) = sor(1, fsc) + 1
  297.   sor(2, fsc) = sor(2, fsc) + OilR
  298.   TotR(1) = TotR(1) + OilR
  299.   'wellpoil=.16*OilR*z(2) ???
  300.     
  301. ' recoverable assoc-dissolved gas, billions of cu. ft.
  302.   adgr = OilR * GOR * 0.001
  303.   Call SizeClass(adgr / 6, maxfsc(9), marray, fsc)
  304.   sgr(2, fsc) = sgr(2, fsc) + adgr
  305.   TotR(2) = TotR(2) + adgr
  306.   
  307. ' recoverable ngl from assoc-diss gas, millions bbl
  308.   nglr = adgr * nglratio * 0.001
  309.   Call SizeClass(nglr, maxfsc(12), marray, fsc)
  310.   snglr(1, fsc) = snglr(1, fsc) + nglr
  311.   TotR(5) = TotR(5) + nglr
  312.  Else
  313.  
  314.  'GAS
  315.  'Note that provision was made for sampling from
  316.  ' separate distributions for non-associated gas
  317.  ' however in this study all hydrocarbon distributions
  318.  ' are specified on the Oil worksheet.
  319.  os = 2     'code for gas
  320.  Call SingleS(pd, 11, depth)    'Sample depth
  321.  depth = depth + depthadd
  322.  If press4 = 0 Or depth <= 10 Then
  323.   press = press1 + press2 * depth 'Pressure, psi
  324.   Else
  325.   press = press3 + press4 * depth
  326.  End If
  327.  temp = temp1 + temp2 * depth
  328.  Call gasc(press, temp, depth, zc)
  329.  Call SampleGHVP(z, pd, zc, temp, press, minfs)
  330.   GasA = z(6)
  331.   
  332.  ' in place NA gas, billions of cu. ft.
  333.   Call SizeClass(GasA / 6, maxfsc(3), marray, fsc) 'size class
  334.   sg(1, fsc) = sg(1, fsc) + 1
  335.   sg(3, fsc) = sg(3, fsc) + GasA
  336.   NDRep(2) = NDRep(2) + 1
  337.   TotIP(3) = TotIP(3) + GasA
  338.   
  339. '  in place natural gas liquids plus condensate to
  340. '    non-associated gas (bbls/million cf)
  341.   If depth >= 15.674 Then
  342.     nglratio = 100       'units=bbl/million cf
  343.     Else
  344.     nglratio = 1000000 / (nglr1 * Exp(nglr2 * depth))
  345.   End If
  346.   nglra = GasA * nglratio * 0.001  'ngl in mm bbl
  347.   Call SizeClass(nglra, maxfsc(6), marray, fsc) 'size class
  348.   sngl(2, fsc) = sngl(2, fsc) + nglra  'ngl from NA gas
  349.   TotIP(6) = TotIP(6) + nglra 'contribution to ngl from NA gas
  350.   
  351.  ' recoverable NA gas
  352.   GasR = GasA * grf   'recoverable gas, billions cu. ft.
  353.   Call SizeClass(GasR / 6, maxfsc(10), marray, fsc)
  354.   sgr(1, fsc) = sgr(1, fsc) + 1
  355.   sgr(3, fsc) = sgr(3, fsc) + GasR
  356.   TotR(3) = TotR(3) + GasR
  357.   'wellprodg=.62*GasR*z(2)
  358.   
  359.   'recov natural gas liquids plus condensate to
  360.   '  non-associated gas(bbls/million cf)
  361.   nglrar = GasR * nglratio * 0.001  'ngl in mm bbl
  362.   Call SizeClass(nglrar, maxfsc(13), marray, fsc) 'size class
  363.   snglr(2, fsc) = snglr(2, fsc) + nglrar  'ngl from NA gas
  364.   TotR(6) = TotR(6) + nglrar 'contribution to ngl from NA gas
  365.   
  366.  End If     'end of oil/gas computations
  367.  
  368.  'get total gas and total ngl
  369.  gast = adg + GasA      'total in-place gas
  370.  If gast > 0 Then
  371.   Call SizeClass(gast / 6, maxfsc(4), marray, fsc) 'size class
  372.   sg(4, fsc) = sg(4, fsc) + gast
  373.   TotIP(4) = TotIP(4) + gast
  374.   gastr = adgr + GasR    'total recoverable gas
  375.   Call SizeClass(gastr / 6, maxfsc(11), marray, fsc) 'size class
  376.   sgr(4, fsc) = sgr(4, fsc) + gastr
  377.   TotR(4) = TotR(4) + gastr
  378.  End If
  379.  nglt = ngl + nglra     'total in-place ngl
  380.  If nglt > 0 Then
  381.   Call SizeClass(nglt, maxfsc(7), marray, fsc) 'size class
  382.   sngl(3, fsc) = sngl(3, fsc) + nglt
  383.   TotIP(7) = TotIP(7) + nglt
  384.   ngltr = nglr + nglrar  'total recoverable ngl
  385.   Call SizeClass(ngltr, maxfsc(14), marray, fsc) 'size class
  386.   snglr(3, fsc) = snglr(3, fsc) + ngltr
  387.   TotR(7) = TotR(7) + ngltr
  388.  End If
  389.  TotClos = TotClos + z(2)
  390.  If i <= 100 Then
  391.   If os = 1 Then
  392.    Write #3, i, njknt, os, z(6), z(1), z(2), z(3), z(4), z(5)
  393.   Else
  394.    Write #3, i, njknt, os, z(6), z(1), z(2), z(3), z(4), z(5)
  395.   End If
  396.  End If
  397.  If os = 1 Then
  398.   Write #1, i, njknt, os, OilR, z(2), depth, adgr, nglr, fvf, GOR, nglratio
  399.  Else
  400.   Write #1, i, njknt, os, GasR, z(2), depth, ngltr, press, temp, zc, nglratio
  401.  End If
  402.  
  403. If nj = 1 Then       'adjust probabilities of discovery
  404.  If nsw = 1 Then
  405.   fNc = 0
  406.   fAc = fcond
  407.   Else
  408.   fNc = fcond
  409.   fAc = 0
  410.  End If
  411.  nj = 2
  412.  GoTo Line10:
  413. End If
  414.   'end of prospect loop
  415. Line60:
  416. If TotClos > Mclos Then Mclos = TotClos
  417. If TotClos > playa Then Ntotc = Ntotc + 1
  418.  
  419. Write #2, i, TotR(1), TotR(2), TotR(3), TotR(4), TotR(5), TotR(6), TotR(7), TotIP(1), TotIP(2), TotIP(3), TotIP(4), TotIP(5), TotIP(6), TotIP(7)
  420. For j = 1 To 7
  421.  tmpIP = TotIP(j) - c(j)
  422.  tmpR = TotR(j) - c(j) * 0.5
  423.  SumIP(j) = SumIP(j) + tmpIP
  424.  SumR(j) = SumR(j) + tmpR
  425.  Sum2IP(j) = Sum2IP(j) + tmpIP * tmpIP
  426.  Sum2R(j) = Sum2R(j) + tmpR * tmpR
  427. Next j
  428. For j = 1 To 2
  429.  NumDep(j) = NumDep(j) + NDRep(j)
  430.  NumDep(j + 2) = NumDep(j + 2) + NDRep(j) * NDRep(j)
  431. Next j
  432.  
  433. Next i    'end of simulation loop
  434.  
  435. 'Summary statistics
  436. ' get averages by size class
  437.  
  438. For i = 1 To 7
  439.  Sum2IP(i) = Sqr((Sum2IP(i) - (SumIP(i) / mdiv) * SumIP(i)) / (mdiv - 1))
  440.  Sum2R(i) = Sqr((Sum2R(i) - (SumR(i) / mdiv) * SumR(i)) / (mdiv - 1))
  441.  SumIP(i) = SumIP(i) / mdiv + c(i)
  442.  SumR(i) = SumR(i) / mdiv + c(i) * 0.5
  443. Next i
  444. For j = 1 To 2
  445.  NumDep(j + 2) = Sqr((mdiv * NumDep(j + 2) - NumDep(j) * NumDep(j)) / ((mdiv - 1) * mdiv))
  446.  NumDep(j) = NumDep(j) / mdiv
  447. Next j
  448. For j = 1 To marray
  449.  For i = 1 To 2
  450.   so(i, j) = so(i, j) / mdiv
  451.   sor(i, j) = sor(i, j) / mdiv
  452.  Next i
  453.  For i = 1 To 3
  454.   sngl(i, j) = sngl(i, j) / mdiv
  455.   snglr(i, j) = snglr(i, j) / mdiv
  456.  Next i
  457.  For i = 1 To 4
  458.   sg(i, j) = sg(i, j) / mdiv
  459.   sgr(i, j) = sgr(i, j) / mdiv
  460.  Next i
  461. Next j
  462.  
  463. Pclos = 100 * Ntotc / m
  464.  
  465. 'Output statistics
  466. Worksheets("Summary").Activate 'in place mean and std dev
  467.   Range("b5").Select
  468.    Selection.Value = SumIP(1)
  469.   Range("c5").Select
  470.    Selection.Value = Sum2IP(1)
  471.   Range("b7").Select
  472.    Selection.Value = SumIP(2)
  473.   Range("c7").Select
  474.    Selection.Value = Sum2IP(2)
  475.   Range("b8").Select
  476.    Selection.Value = SumIP(3)
  477.   Range("c8").Select
  478.    Selection.Value = Sum2IP(3)
  479.   Range("b9").Select
  480.    Selection.Value = SumIP(4)
  481.   Range("c9").Select
  482.    Selection.Value = Sum2IP(4)
  483.   Range("b11").Select
  484.    Selection.Value = SumIP(5)
  485.   Range("c11").Select
  486.    Selection.Value = Sum2IP(5)
  487.   Range("b12").Select
  488.    Selection.Value = SumIP(6)
  489.   Range("c12").Select
  490.    Selection.Value = Sum2IP(6)
  491.   Range("b13").Select
  492.    Selection.Value = SumIP(7)
  493.   Range("c13").Select
  494.    Selection.Value = Sum2IP(7)
  495.   Range("b17").Select            'recoverable mean and std dev
  496.    Selection.Value = SumR(1)
  497.   Range("c17").Select
  498.    Selection.Value = Sum2R(1)
  499.   Range("b19").Select
  500.    Selection.Value = SumR(2)
  501.   Range("c19").Select
  502.    Selection.Value = Sum2R(2)
  503.   Range("b20").Select
  504.    Selection.Value = SumR(3)
  505.   Range("c20").Select
  506.    Selection.Value = Sum2R(3)
  507.   Range("b21").Select
  508.    Selection.Value = SumR(4)    ' Mean NA Gas
  509.   Range("c21").Select
  510.    Selection.Value = Sum2R(4)
  511.   Range("b23").Select
  512.    Selection.Value = SumR(5)
  513.   Range("c23").Select
  514.    Selection.Value = Sum2R(5)
  515.   Range("b24").Select
  516.    Selection.Value = SumR(6)    ' Mean NA Gas
  517.   Range("c24").Select
  518.    Selection.Value = Sum2R(6)
  519.   Range("b25").Select
  520.    Selection.Value = SumR(7)
  521.   Range("c25").Select
  522.    Selection.Value = Sum2R(7)
  523.   Range("b28").Select
  524.    Selection.Value = NumDep(1)  ' Number of pools, mean and std.dev
  525.   Range("c28").Select
  526.    Selection.Value = NumDep(3)
  527.   Range("b29").Select
  528.    Selection.Value = NumDep(2)
  529.   Range("c29").Select
  530.    Selection.Value = NumDep(4)
  531.  
  532.   Range("b32").Select
  533.    Selection.Value = m      'number of simulations
  534.   Range("b33").Select
  535.    Selection.Value = mdiv   'number of play runs
  536.    
  537. Worksheets("Distns").Activate
  538.   Range("b5:n6").Select     'in place
  539.    Selection.Value = so     'num and oil
  540.   Range("b9:n12").Select
  541.    Selection.Value = sg     'num NA gas, ass dis gas & NA gas
  542.   Range("b16:n18").Select
  543.    Selection.Value = sngl   'ngl from ass dis gas & NA gas
  544.   Range("b22:n23").Select   'recoverable
  545.    Selection.Value = sor    'num and oil
  546.   Range("b26:n29").Select
  547.    Selection.Value = sgr    'num NA gas, ass dis gas & NA gas
  548.   Range("b33:n35").Select
  549.    Selection.Value = snglr  'ngl from ass dis gas & NA gas
  550.     
  551. Worksheets("Supple").Activate
  552.   Range("e5").Select
  553.    Selection.Value = Mclos   'Max area of closures
  554.   Range("e6").Select
  555.    Selection.Value = Pclos   '%total closure>play area|success
  556.   Range("e13:r13").Select
  557.    Selection.Value = maxfsc  'Max field size classes
  558.   Range("e8").Select
  559.    Selection.Value = marray  'Max num log 2 size classes
  560.   Range("e3").Select
  561.    Selection.Value = seed    'Random number seed
  562. Close #1
  563. Close #2
  564. Close #3
  565. ' Close #9
  566.  
  567. End Sub
  568. Sub SampleOHVP(z, pd, fvf, minfs)
  569. ' Computes Oil in place >= cutoff
  570. '  Note correlation between z(3) [porosity] and
  571. '   z(4)[1-ws] is one.
  572. Dim prod As Variant, j As Integer, k As Integer, u As Variant
  573. Dim j2 As Integer
  574. Line1:
  575.  prod = 1
  576.   For j = 1 To 5
  577.     If j <> 4 Then u = Rnd
  578.     j2 = j * 2 - 1
  579.      For k = 2 To 7
  580.        If u > pd(k - 1, j2 + 1) And u <= pd(k, j2 + 1) Then
  581.          z(j) = pd(k - 1, j2) + ((u - pd(k - 1, j2 + 1)) / (pd(k, j2 + 1) - pd(k - 1, j2 + 1))) * (pd(k, j2) - pd(k - 1, j2))
  582.          prod = prod * z(j)
  583.        End If
  584.      Next k
  585.   Next j
  586. ' in place oil in millions of bbl
  587. z(6) = prod * 7.758 * 10 ^ -6 / fvf
  588. If z(6) >= minfs Then
  589.  Exit Sub
  590. Else
  591.  GoTo Line1
  592. End If
  593. End Sub
  594. Sub SampleGHVP(z, pd, zc, temp, press, minfs)
  595. ' Computes Gas in place >= cutoff
  596. '  Note correlation between z(3) and z(4) is one.
  597. Dim prod As Variant, j As Integer, k As Integer, u As Variant
  598. Dim j2 As Integer
  599. Line1:
  600.  prod = 1
  601.   For j = 1 To 5
  602.     If j <> 4 Then u = Rnd
  603.     j2 = j * 2 - 1
  604.      For k = 2 To 7
  605.        If u > pd(k - 1, j2 + 1) And u <= pd(k, j2 + 1) Then
  606.          z(j) = pd(k - 1, j2) + ((u - pd(k - 1, j2 + 1)) / (pd(k, j2 + 1) - pd(k - 1, j2 + 1))) * (pd(k, j2) - pd(k - 1, j2))
  607.          prod = prod * z(j)
  608.        End If
  609.      Next k
  610.   Next j
  611. 'in place gas in billions of cu ft
  612. z(6) = prod * 0.00000154 * (press / temp) / zc
  613. ' 1540e-09=43.56 * 10 ^ -9 * (519.7 / 14.7)
  614. If z(6) / 6 >= minfs Then
  615.  Exit Sub
  616. Else
  617.  GoTo Line1
  618. End If
  619. End Sub
  620. Sub SingleS(pd, j, z)
  621. ' Random Deviate from Fractile Distribution
  622. Dim k As Integer, u As Variant
  623.  
  624.    u = Rnd
  625.     For k = 2 To 7
  626.        If u > pd(k - 1, j + 1) And u <= pd(k, j + 1) Then
  627.          z = pd(k - 1, j) + ((u - pd(k - 1, j + 1)) / (pd(k, j + 1) - pd(k - 1, j + 1))) * (pd(k, j) - pd(k - 1, j))
  628.        End If
  629.     Next k
  630. End Sub
  631. Sub SizeClass(size, maxf, marray, fsc)
  632. ' Computes size class in log based 2
  633.  fsc = Int(Log(size) / Log(2)) - 1 ' size class
  634.   If fsc < 1 Then fsc = 1
  635.   If fsc > maxf Then maxf = fsc
  636.   If fsc > marray Then fsc = marray
  637.  End Sub
  638. Sub gasc(p0, t0, depth, z)
  639. 'Estimates gas compressibility
  640. '  Ref: Microcomputer Programs for Petroleum Engineers
  641. '  p- pressure
  642. '  t- degrees Rankine
  643. '  depth- 1000 ft
  644. '  z- gas compressibility
  645.  
  646. Dim dr(1 To 6), drp(1 To 6)
  647. Dim i, k As Integer
  648. Dim a, b, c, e, f, g, t2, fdr, gdr, t, p As Variant
  649. If depth <= 3 Then      'depth <=3,000 ft
  650.   z = 1 - 0.11 * depth + 0.0125 * depth * depth
  651.   Exit Sub
  652. End If
  653. ' Use Mricocompute algorithm for depths > 3000 ft
  654. ' t and p are reducted temperature and pressure
  655. '  using gas gravity of 0.6 and Fig 17 furnished by
  656. '  John Quinn
  657. t = t0 / 358
  658. p = p0 / 672
  659. a = 0.06423
  660. f = 0.6845
  661. dr(1) = 0.27 * p / t
  662.  
  663. b = 0.5353 * t - 0.6123
  664. t2 = t * t
  665. c = 0.3151 * t - 1.0467 - (0.5783 / t2)
  666. e = 0.6816 / t2
  667. g = 0.27 * p
  668. For i = 1 To 5
  669. drp(1) = dr(i)
  670. For k = 2 To 6
  671.  drp(k) = drp(k - 1) * drp(1)
  672. Next k
  673. fdr = a * drp(6) + b * drp(3) + c * drp(2) + t * drp(1) + e * drp(3) * (1 + f * drp(2)) * Exp(-f * drp(2)) - g
  674. gdr = 6 * a * drp(5) + 3 * drp(2) + 2 * c * drp(1) + t + e * drp(2) * (3 + f * drp(2) * (3 - 2 * f * drp(2))) * Exp(-f * drp(2))
  675. dr(i + 1) = dr(i) - fdr / gdr
  676. Next i
  677. z = dr(6)
  678. End Sub
  679. 1
  680.  
  681.  
  682. 1
  683.  
  684.  
  685.